package com.kws.tool.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.kws.common.core.domain.R;
import com.kws.tool.dto.*;
import com.kws.tool.entity.CalculationFormOptionsEntity;
import com.kws.tool.entity.FeedInTariffEntity;
import com.kws.tool.service.CalculationService;
import com.kws.tool.service.PhotovoltaicService;
import com.kws.tool.service.PolicyService;
import com.kws.tool.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : zhangbenting
 * @date : 2024/10/22 15:54
 * @Version: 1.0
 */
@RequestMapping("/ToolManage")
@RestController
@Api(value = "用户服务系统-工具管理", tags = "用户服务系统-工具管理")
public class ToolManageController {

    @Autowired
    private PolicyService policyService;

    @Autowired
    private PhotovoltaicService photovoltaicService;

    @Autowired
    private CalculationService calculationService;

    @ApiOperation("获取政策列表")
    @PostMapping("/getPolicyList")
    public R<Page<PolicyVo>> getPolicyList(@RequestBody PolicyDto policyDto) {
        return R.ok(policyService.getPolicyList(policyDto));
    }

    @ApiOperation("获取标准列表")
    @PostMapping("/getStandardList")
    public R<Page<StandardVo>> getStandardList(@RequestBody StandardDto standardDto) {
        return R.ok(policyService.getStandardList(standardDto));
    }

    @ApiOperation("获取标准工具类型")
    @GetMapping("/getStandardToolType")
    public R<List<ToolTypeVo>> getStandardToolType() {
        return R.ok(policyService.getStandardToolType());
    }

    @ApiOperation("获取省市区列表")
    @GetMapping("/getLocationList")
    public R<List<LocationVo>> getLocationList() {
        return R.ok(policyService.getLocationList());
    }

    @ApiOperation("获取政策级别和发文机关")
    @GetMapping("/getPolicyLevelAndOrgan")
    public R<LevelAndOrganDto> getPolicyLevelAndOrgan() {
        return R.ok(policyService.getPolicyLevelAndOrgan());
    }

    @ApiOperation("添加政策或标准收藏")
    @PostMapping("/addPolicyOrStandardCollect")
    public R<Boolean> addPolicyOrStandardCollect(@RequestBody CollectDto collectDto) {
        return R.ok(policyService.addPolicyOrStandardCollect(collectDto));
    }

    @ApiOperation("获取标准收藏列表")
    @PostMapping("/getStandardCollectList")
    public R<Page<StandardVo>> getStandardCollectList(@RequestBody StandardDto standardDto) {
        return R.ok(policyService.getStandardCollectList(standardDto));
    }

    @ApiOperation("获取政策收藏列表")
    @PostMapping("/getPolicyCollectList")
    public R<Page<PolicyVo>> getPolicyCollectList(@RequestBody PolicyDto policyDto) {
        return R.ok(policyService.getPolicyCollectList(policyDto));
    }

    @ApiOperation("删除政策或标准收藏")
    @PostMapping("/removePolicyOrStandardCollect")
    public R<Boolean> removePolicyOrStandardCollect(@RequestBody CollectDto collectDto) {
        return R.ok(policyService.removePolicyOrStandardCollect(collectDto));
    }

    @ApiOperation("添加政策或标准浏览量")
    @PostMapping("/addPolicyOrStandardBrowse")
    public R<Boolean> addPolicyOrStandardBrowse(@RequestBody CollectDto collectDto) {
        return R.ok(policyService.addPolicyOrStandardBrowse(collectDto));
    }

    @ApiOperation("获取地区和用电类型I")
    @PostMapping("getRegionAndElectricityTypeI")
    @ApiOperationSupport(order = 1, includeParameters = {
            "electricityPriceDto.type"
    })
    public R<List<RegionVo>> getRegionAndElectricityTypeI(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getRegionAndElectricityTypeI(electricityPriceDto));
    }

    @ApiOperation("获取用电类型II电压等级")
    @PostMapping("getVoltageAndElectricityTypeII")
    @ApiOperationSupport(order = 2, includeParameters = {
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.regionName"
    })
    public R<List<VoltageVo>> getVoltageAndElectricityTypeII(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getVoltageAndElectricityTypeII(electricityPriceDto));
    }

    @ApiOperation("月份选择")
    @PostMapping("/getMonthChoose")
    @ApiOperationSupport(order = 3, includeParameters = {
            "electricityPriceDto.regionName",
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.electricityTypeTwoName",
            "electricityPriceDto.tariffLevelId"
    })
    public R<List<MonthChooseVo>> getMonthChoose(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getMonthChoose(electricityPriceDto));
    }

    @ApiOperation("获取分时电价图表")
    @PostMapping("getDivideHourElectricity")
    @ApiOperationSupport(order = 4, includeParameters = {
            "electricityPriceDto.regionName",
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.electricityTypeTwoName",
            "electricityPriceDto.tariffLevelId",
            "electricityPriceDto.years"
    })
    public R<List<DivideHourVo>> getDivideHourElectricity(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getDivideHourElectricity(electricityPriceDto));
    }

    @ApiOperation("获取分月电价图表")
    @PostMapping("getDivideMonthElectricity")
    @ApiOperationSupport(order = 5, includeParameters = {
            "electricityPriceDto.regionName",
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.electricityTypeTwoName",
            "electricityPriceDto.tariffLevelId"
    })
    public R<List<DivideMonthVo>> getDivideMonthElectricity(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getDivideMonthElectricity(electricityPriceDto));
    }

    @ApiOperation("获取峰谷差价图表")
    @PostMapping("getPeakValleyPriceDifference")
    @ApiOperationSupport(order = 6, includeParameters = {
            "electricityPriceDto.regionName",
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.electricityTypeTwoName",
            "electricityPriceDto.tariffLevelId"
    })
    public R<List<PeakValleyVo>> getPeakValleyPriceDifference(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getPeakValleyPriceDifference(electricityPriceDto));
    }

    @ApiOperation("获取电压等级(电价分析)")
    @PostMapping("getElectricityLevel")
    @ApiOperationSupport(order = 7, includeParameters = {
            "electricityPriceDto.electricityTypeOneName"
    })
    public R<List<MonthChooseVo>> getElectricityLevel(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getElectricityLevel(electricityPriceDto));
    }

    @ApiOperation("获取月份选择(电价分析)")
    @PostMapping("getMonthChooseElectricity")
    @ApiOperationSupport(order = 7, includeParameters = {
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.regionName"
    })
    public R<List<MonthChooseVo>> getMonthChooseElectricity(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getMonthChooseElectricity(electricityPriceDto));
    }

    @ApiOperation("获取峰谷价差(电价分析)")
    @PostMapping("getPeakValleySpread")
    public R<List<MonthChooseVo>> getPeakValleySpread() {
        return R.ok(photovoltaicService.getPeakValleySpread());
    }

    @ApiOperation("获取电价分析图表")
    @PostMapping("getElectricityPriceAnalysis")
    @ApiOperationSupport(order = 7, includeParameters = {
            "electricityPriceDto.regionNameList",
            "electricityPriceDto.electricityTypeOneName",
            "electricityPriceDto.tariffLevelId",
            "electricityPriceDto.years",
            "electricityPriceDto.differencePrice"
    })
    public R<List<AnalysisVo>> getElectricityPriceAnalysis(@RequestBody ElectricityPriceDto electricityPriceDto) {
        return R.ok(photovoltaicService.getElectricityPriceAnalysis(electricityPriceDto));
    }

    @ApiOperation("获取测算参数")
    @GetMapping("/getCalculationFormOptions")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "calculationType", value = "测算类型", dataType = "String", required = true),
    })
    public R<List<CalculationFormOptionsVo>> getCalculationFormOptions(@RequestParam String calculationType) {
        return R.ok(calculationService.getCalculationFormOptions(calculationType));
    }

    @ApiOperation("获取各省电价和年发小时数")
    @GetMapping("/getFeedInTariff")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "economize", value = "区域名称", dataType = "String"),
    })
    public R<FeedInTariffVo> getFeedInTariff(@RequestParam String economize) {
        return R.ok(calculationService.getFeedInTariff(economize));
    }

    @ApiOperation("获取安装区域")
    @GetMapping("/getRegionName")
    public R<List<RegionNameVo>> getRegionName() {
        return R.ok(calculationService.getRegionName());
    }

    @ApiOperation("光伏测算")
    @PostMapping("/photovoltaicCalculation")
    public R<PhotovoltaicVo> photovoltaicCalculation(@RequestBody PhotovoltaicDto photovoltaicDto) {
        return R.ok(calculationService.photovoltaicCalculation(photovoltaicDto));
    }

    @ApiOperation("储能测算")
    @PostMapping("/energyStorageCalculation")
    public R<EnergyStorageVo> energyStorageCalculation(@RequestBody EnergyStorageDto energyStorageDto) {
        return R.ok(calculationService.energyStorageCalculation(energyStorageDto));
    }

    @ApiOperation("充电桩测算")
    @PostMapping("/electricPileCalculation")
    public R<ElectricPileVo> electricPileCalculation(@RequestBody ElectricPileDto electricPileDto) {
        return R.ok(calculationService.electricPileCalculation(electricPileDto));
    }

    @ApiOperation("风电测算")
    @PostMapping("/windPowerCalculation")
    public R<WindPowerVo> windPowerCalculation(@RequestBody WindPowerDto windPowerDto) {
        return R.ok(calculationService.windPowerCalculation(windPowerDto));
    }

    @ApiOperation("微网测算(光储一体化)")
    @PostMapping("/lightStorageMicroNetwork")
    public R<LightStorageMicroNetworkVo> LightStorageMicroNetwork(@RequestBody LightStorageMicroNetworkDto lightStorageMicroNetworkDto) {
        return R.ok(calculationService.lightStorageMicroNetwork(lightStorageMicroNetworkDto));
    }

    @ApiOperation("微网测算(光储充一体化)")
    @PostMapping("/lightStorageCharging")
    public R<LightStorageChargingVo> lightStorageCharging(@RequestBody LightStorageChargingDto lightStorageChargingDto) {
        return R.ok(calculationService.lightStorageCharging(lightStorageChargingDto));
    }

    @ApiOperation("更新地区和用电类型I")
    @PostMapping("updateRegionAndElectricityTypeIData")
    public R<Boolean> updateRegionAndElectricityTypeIData() {
        return R.ok(photovoltaicService.updateRegionAndElectricityTypeIData());
    }

    @ApiOperation("更新用电类型II电压等级")
    @PostMapping("updateVoltageAndElectricityTypeII")
    public R<Boolean> updateVoltageAndElectricityTypeII() {
        return R.ok(photovoltaicService.updateVoltageAndElectricityTypeII());
    }

    @ApiOperation("更新月份选择")
    @PostMapping("/updateMonthChoose")
    public R<Boolean> updateMonthChoose() {
        return R.ok(photovoltaicService.updateMonthChoose());
    }

    @ApiOperation("更新分时电价图表")
    @PostMapping("updateDivideHourElectricity")
    public R<Boolean> updateDivideHourElectricity() {
        return R.ok(photovoltaicService.updateDivideHourElectricity());
    }

    @ApiOperation("更新分月电价图表")
    @PostMapping("updateDivideMonthElectricity")
    public R<Boolean> updateDivideMonthElectricity() {
        return R.ok(photovoltaicService.updateDivideMonthElectricity());
    }

    @ApiOperation("更新峰谷差价图表")
    @PostMapping("updatePeakValleyPriceDifference")
    public R<Boolean> updatePeakValleyPriceDifference() {
        return R.ok(photovoltaicService.updatePeakValleyPriceDifference());
    }

    @ApiOperation("更新电压等级(电价分析)")
    @PostMapping("updateElectricityLevel")
    public R<Boolean> updateElectricityLevel() {
        return R.ok(photovoltaicService.updateElectricityLevel());
    }

    @ApiOperation("更新月份选择(电价分析)")
    @PostMapping("updateMonthChooseElectricity")
    public R<Boolean> updateMonthChooseElectricity() {
        return R.ok(photovoltaicService.updateMonthChooseElectricity());
    }

    @ApiOperation("更新峰谷价差(电价分析)")
    @PostMapping("updatePeakValleySpread")
    public R<Boolean> updatePeakValleySpread() {
        return R.ok(photovoltaicService.updatePeakValleySpread());
    }

    @ApiOperation("更新电价分析图表")
    @PostMapping("updateElectricityPriceAnalysis")
    public R<Boolean> updateElectricityPriceAnalysis() {
        return R.ok(photovoltaicService.updateElectricityPriceAnalysis());
    }

    //    @ApiOperation("获取测试")
//    @PostMapping("getTest")
//    public R<List<DivideHourVo>> getTest(@RequestBody ElectricityPriceDto electricityPriceDto) {
//        return R.ok(photovoltaicService.getTest(electricityPriceDto));
//    }
    @ApiOperation("根据电站cid修改电价信息")
    @PostMapping("updateElectricityPriceByCId")
    public R<Boolean> updateElectricityPriceByCId(@RequestBody ElectricityPriceByCIdDto electricityPriceByCIdDto) {
        return R.ok(photovoltaicService.updateElectricityPriceByCId(electricityPriceByCIdDto));
    }

    @ApiOperation("根据电站cid获取电价信息")
    @PostMapping("getElectricityPriceByCId")
    @ApiOperationSupport(order = 7, includeParameters = {
            "electricityPriceByCIdDto.cid"
    })
    public R<List<DivideHourVo>> getElectricityPriceByCId(@RequestBody ElectricityPriceByCIdDto electricityPriceByCIdDto) {
        return R.ok(photovoltaicService.getElectricityPriceByCId(electricityPriceByCIdDto));
    }
}
